package com.zzq.service.impl;

import com.zzq.mapper.AdminMapper;
import com.zzq.pojo.Admin;
import com.zzq.pojo.Bidder;
import com.zzq.pojo.vo.DatebaseAnalyze;
import com.zzq.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin findByAdminName(String username) {
        Admin admin =adminMapper.findByAdminName(username);
        return admin;
    }

    @Override
    public void updatePassword(String username, String newPwd) {
        adminMapper.updatePassword(username,newPwd);
    }

    @Override
    public DatebaseAnalyze getDatebase() {
        int ongoingProjects= adminMapper.getOngoingProjects();
        int pendingReviews=adminMapper.getPendingReviews();
        Double monthlyRevenue=adminMapper.getMonthlyRevenue();
        int bids=adminMapper.getBids();
        int tender=adminMapper.getTender();
        int success=adminMapper.getSuccess();

        DatebaseAnalyze datebaseAnalyze= DatebaseAnalyze.builder()
                .ongoingProjects(ongoingProjects)
                .pendingReviews(pendingReviews)
                .monthlyRevenue(monthlyRevenue)
                .bids(bids)
                .tender(tender)
                .success(success)
                .build();
        return datebaseAnalyze;

    }
}
